package cn.itcast.feign.clients;


import cn.itcast.feign.fallback.UserClientFallbackFactory;
import cn.itcast.feign.pojo.User;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;

/**
 * 如果调用UserClient下的方法出现异常，
 * 会去调用UserClientFallbackFactory中的代码
 * UserClientFallbackFactory需要在DefaultFeignConfiguration注入bean
 * 还需在application.yml中开启feign.sentinel.enabled:true
 */
@FeignClient(value = "userservice",fallbackFactory = UserClientFallbackFactory.class)
public interface UserClient {

    @GetMapping("/user/{id}")
    User findById(@PathVariable("id") Long id);
}
